import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BillDetailsVO, BillDetailsForm, BillDetailsQuery } from '@/api/crmbill/billDetails/types';

/**
 * 查询账单明细列表
 * @param query
 * @returns {*}
 */

export const listBillDetails = (query?: BillDetailsQuery): AxiosPromise<BillDetailsVO[]> => {
  return request({
    url: '/crmbill/billDetails/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询账单明细详细
 * @param billId
 */
export const getBillDetails = (billId: string | number): AxiosPromise<BillDetailsVO> => {
  return request({
    url: '/crmbill/billDetails/' + billId,
    method: 'get'
  });
};

/**
 * 新增账单明细
 * @param data
 */
export const addBillDetails = (data: BillDetailsForm) => {
  return request({
    url: '/crmbill/billDetails',
    method: 'post',
    data: data
  });
};

/**
 * 修改账单明细
 * @param data
 */
export const updateBillDetails = (data: BillDetailsForm) => {
  return request({
    url: '/crmbill/billDetails',
    method: 'put',
    data: data
  });
};

/**
 * 删除账单明细
 * @param billId
 */
export const delBillDetails = (billId: string | number | Array<string | number>) => {
  return request({
    url: '/crmbill/billDetails/' + billId,
    method: 'delete'
  });
};
